package com.system.outpatientsystem.controller;

import com.system.outpatientsystem.pojo.Result;
import com.system.outpatientsystem.utils.JwtUtils;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/hello")
public class HelloController {

    @GetMapping("/hello")
    public String hello(){
        return "hello world";
    }

    @GetMapping("/search")
    public Result<String> search(@RequestHeader(name = "Authorization") String token, HttpServletResponse response){
        //验证token
//        try{
//            Map<String, Object> claims = JwtUtils.parseToken(token);
//            return Result.success("claims");
//        } catch (Exception e) {
//            //http响应状态吗为401
//            response.setStatus(401);
//            return Result.error("未登录");
//        }
        return Result.success("claims");
    }
}
